package com.luo.service;

import com.luo.mapper.CarMapper;
import com.luo.pojo.car;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class CarService {

    @Resource
    private CarMapper carMapper;

    public Map<String,Object> selectCarList(){
        Map<String,Object> map = new HashMap<>();
        List<car> cars = carMapper.selectCarList();
        map.put("code", 0);
        map.put("msg", "");
        map.put("data", cars);
        return map;
    }

    public Map<String,Object> delete(Integer id){
        Map<String,Object> map = new HashMap<>();
        carMapper.delete(id);
        map.put("code", 200);
        map.put("msg", "删除成功");
        map.put("data", "");
        return map;
    }

    public Map<String,Object> selectCars(){
        Map<String,Object> map = new HashMap<>();
        List<car> cars = carMapper.selectCars();
        map.put("code", 0);
        map.put("msg", "");
        map.put("data", cars);
        return map;
    }
}
